local Resolution = Vector2.new(160, 120) local LossAmount = .075 local CF = owner.Character.HumanoidRootPart.CFrame local Hash33: (Vector3) -> Vector3 local Hash23: (Vector2) -> Vector3 local Hash22: (Vector2) -> Vector2 local Hash21: (Vector2) -> number local Hash31: (Vector3) -> number do --Hash functions local Hash33A = Vector3.new(67.47834, 52.5363, 67.4353) local Hash33B = Vector3.new(84.25652, 76.4533, 34.5474) local Hash33C = Vector3.new(32.63437, 56.7483, 87.2445) function Hash33(Point:Vector3):Vector3 return Vector3.new( (math.cos(Point:Dot(Hash33A)) * 45363.46356) % 1, (math.cos(Point:Dot(Hash33B)) * 34364.57434) % 1, (math.cos(Point:Dot(Hash33C)) * 67343.64473) % 1 ) end local Hash23A = Vector2.new(67.47834, 52.5363) local Hash23B = Vector2.new(84.25652, 34.5474) local Hash23C = Vector2.new(56.74834, 87.2445) function Hash23(Point:Vector2):Vector3 return Vector3.new( (math.cos(Point:Dot(Hash23A)) * 35637.46356) % 1, (math.cos(Point:Dot(Hash23B)) * 15663.57434) % 1, (math.cos(Point:Dot(Hash23C)) * 13633.64473) % 1 ) end function Hash22(Point:Vector2):Vector2 return Vector2.new( (math.cos(Point:Dot(Hash23B)) * 15663.57434) % 1, (math.cos(Point:Dot(Hash23C)) * 13633.64473) % 1 ) end function Hash21(Point:Vector2):number return (math.cos(Point:Dot(Hash23A)) * 64671.76782) % 1 end function Hash31(Point:Vector3):number return (math.cos(Point:Dot(Hash33B)) * 64671.76782) % 1 end end local CamPos = CF.Position + CF.LookVector * 3.1 local CamRot = CF - CF.Position CamRot = CamRot * CFrame.Angles(0, math.pi, 0) local LightNormal = Vector3.new(-0.47034597396850586, 0.819191575050354, 0.3281765282154083) local ApplyMaterial ApplyMaterial = { [Enum.Material.Grass] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) --Normals local Instance = Result.Instance local Hit = Result.Position local Checker = (math.floor(Hit.X * .25) + math.floor(Hit.Y * .25) + math.floor(Hit.Z * .25)) % 2 * .2 + .8 local Color = Instance.Color Color = Vector3.new(Color.R, Color.G, Color.B) * (Hash21(Uv) * .4 + .6) * Checker return Color end, [Enum.Material.SmoothPlastic] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) local Instance = Result.Instance local Color = Instance.Color Color = Vector3.new(Color.R, Color.G, Color.B) return Color end, [Enum.Material.Plastic] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) local Instance = Result.Instance local Color = Instance.Color Color = Vector3.new(Color.R, Color.G, Color.B) return Color end, [Enum.Material.Brick] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) local Instance = Result.Instance local Color = Instance.Color local Height = math.floor(Uv.Y) if Height - Uv.Y > -.15 then Color = Vector3.one * .5 else local _X = Uv.X * .5 + Height * .5 local X = math.floor(_X) if X - _X > -.15 then Color = Vector3.one * .5 else local Num = Hash21(Vector2.new(X, Height)) * .4 + .4 + Hash21(Vector2.new(Uv.X, Uv.Y)) * .2 Color = Vector3.new(Color.R * Num, Color.G * Num, Color.B * Num) end end return Color end, [Enum.Material.Wood] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) local Instance = Result.Instance local Color = Instance.Color Color = Vector3.new(Color.R, Color.G, Color.B) Color = Color * (Hash21(Vector2.new(math.floor((Uv.X + math.cos(Uv.Y * math.pi * 8) * .75) * 3) * .33333)) * .4 + .6) return Color end, [Enum.Material.WoodPlanks] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) local Instance = Result.Instance local Height = math.floor(Uv.Y) local Color = Instance.Color Color = Vector3.new(Color.R, Color.G, Color.B) Color = Color * (Hash21(Vector2.new(math.floor((Uv.X + math.cos(Uv.Y * math.pi * 10 + Height) * .75) * 3) * .33333)) * .5 + .5) if Height - Uv.Y > -.225 then Color = Color * .3 else local _X = Uv.X * .125 + Height * .6942 local X = math.floor(_X) if X - _X > -.025 then Color = Color * .3 else local Num = Hash21(Vector2.new(X, Height)) * .4 + Hash21(Vector2.new(Uv.X, Uv.Y)) * .1 + .5 Color = Color * Num end end return Color end, [Enum.Material.Fabric] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) local Instance = Result.Instance local Color = Instance.Color Color = Vector3.new(Color.R, Color.G, Color.B) local Hash = Hash21(Uv) local YWave = math.cos((Uv.Y * 4 + math.cos(Uv.X * math.pi * 2) * .15) * math.pi) * .1 + math.cos(Uv.Y * math.pi * 1.5) * .1 + .8 local XWave = math.cos((Uv.X * 4 + math.cos(Uv.Y * 2) * .1) * math.pi) * .5 + .5 local Color = Color * (YWave * YWave * YWave * .8 + Hash * Hash * Hash * .2) * (1 - XWave * XWave * XWave * XWave * .4) return Color end, [Enum.Material.Sand] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) local Instance = Result.Instance local Color = Instance.Color Color = Vector3.new(Color.R, Color.G, Color.B) local X = Uv.X * (math.cos(Uv.Y) * .2 + .8) local Y = (Uv.Y * (math.cos(Uv.X + 1.235) * .2 + .8)) * 2 local Wave = math.cos(Y * 3 - math.cos(X * 2) * .4 + math.cos(X * 4) * .3 + math.cos(X * 3) * .1) * .5 + .5 local Noise = Hash21(Uv) return Color * ((1 - (Wave * Wave * Wave) * .2) * (Noise * Noise * Noise * .1 + .9)) end, [Enum.Material.Granite] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) local Instance = Result.Instance local Color = Instance.Color Color = Vector3.new(Color.R, Color.G, Color.B) local Max = (math.cos(Uv.X * 1.4) * .5 - math.cos(Uv.Y * .7) + 2) local WaveX = ((Uv.Y - math.cos(Uv.X * 4) * .2 + math.cos(Uv.X * 7) * .1 + math.cos(Uv.X * 9) * .05) % Max) / Max local WaveY = ((Uv.X - math.cos(Uv.Y * 8) * .2 + math.cos(Uv.Y * 10) * .1 + math.cos(Uv.X * 15) * .05) % Max) / Max local Noise = Hash21(Uv) return Color * ((WaveX * WaveX * WaveX * .4 + .6) * (WaveY * WaveY * WaveY * .4 + .6) * (Noise * Noise * Noise * .4 + .6)) end, [Enum.Material.Slate] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) local Instance = Result.Instance local Color = Instance.Color Color = Vector3.new(Color.R, Color.G, Color.B) local Y = Uv.Y + Uv.X * .2 + math.cos(Uv.X * 1.7 + 2.53) * .3 + math.cos(Uv.X * 2) * .2 local X = Uv.X + math.cos(Uv.Y * 1.6448 + .234) * .2 local WaveXY = math.cos(X + Y * 3 + math.cos(Y * 5) * .3 + math.cos(X * 5) * .3) * .5 + .5 local WaveYX = math.cos(X - Y * 3 + math.cos(Y * 5) * .3 + math.cos(X * 5) * .3) * .5 + .5 return Color * math.clamp(math.abs(.5 - WaveXY * WaveXY) * math.abs(.5 - WaveYX * WaveYX) + .8, 0, 1) * (Hash21(Uv) * .3 + .7) end, [Enum.Material.Concrete] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) local Instance = Result.Instance local Color = Instance.Color Color = Vector3.new(Color.R, Color.G, Color.B) local Hash = Hash21(Uv * .5) local Hash2 = Hash21(Uv * 10) return Color * ((1 - Hash * Hash * Hash * Hash * Hash * Hash * .3) * (Hash2 * .1 + .9)) end, [Enum.Material.Cobblestone] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) local Instance = Result.Instance local Color = Instance.Color Color = Vector3.new(Color.R, Color.G, Color.B) local Y = Uv.Y + Uv.X * .2 + math.cos(Uv.X * 1.7 + 2.53) * .3 + math.cos(Uv.X * 2) * .2 local X = Uv.X + math.cos(Uv.Y * 1.6448 + .234) * .2 local WaveXY = math.cos(X + Y * 3 + math.cos(Y * 5) * .3 + math.cos(X * 5) * .3) * .5 + .5 local WaveYX = math.cos(X - Y * 3 + math.cos(Y * 5) * .3 + math.cos(X * 5) * .3) * .5 + .5 local Sum = math.clamp(math.abs(1 - WaveXY * WaveXY * WaveXY * WaveXY * WaveXY * WaveXY * WaveXY * 2) * math.abs(1 - WaveYX * WaveYX * WaveYX * WaveYX * WaveYX * WaveYX * WaveYX * 2), .5, 1) return Color * (Sum * .7) + Vector3.one * (Hash21(Uv) * ((1 - Sum) * .1 + .05) + .1) end, [Enum.Material.Pebble] = function(Uv:Vector2, Result:RaycastResult, BouncesLeft) local Instance = Result.Instance local Color = Instance.Color Color = Vector3.new(Color.R, Color.G, Color.B) Uv = Vector2.new(Uv.X * (math.cos(Uv.Y * 2) * .1 + .9) + math.cos(Uv.Y + 1.436) * .3 + math.cos(Uv.Y * 3 + 1.436) * .1, Uv.Y * (math.cos(Uv.X * 2) * .1 + .9) + math.cos(Uv.X * 2) * .3 + math.cos(Uv.X * 4 + 2.4) * .1) Uv = Uv * 3 local LocalUv = Vector2.new(Uv.X % 1, Uv.Y % 1) Uv = Uv - LocalUv local Size = Hash21(Uv) * .8 + .3 LocalUv = Vector2.new(LocalUv.X + math.cos(Uv.Y * 3) * .3, LocalUv.Y + math.cos(Uv.X * 3 + 1) * .3) local MoveBy = 1 - Size local Hash1 = Hash22(Uv) * (MoveBy - Size) + Vector2.one * Size local Noise = Hash21(Uv) * .3 + .7 return Color * (Noise * math.clamp((LocalUv - Hash1).Magnitude / Size, .3, .6)) end } local NormalIds = { [Vector3.yAxis] = function(Vec3:Vector3):Vector2 return Vector2.new(Vec3.X, Vec3.Z) end, [Vector3.xAxis] = function(Vec3:Vector3):Vector2 return Vector2.new(Vec3.Z, Vec3.Y) end, [Vector3.zAxis] = function(Vec3:Vector3):Vector2 return Vector2.new(Vec3.X, Vec3.Y) end, } local Colors = table.create(Resolution.Y) for i = 1, Resolution.Y do table.insert(Colors, table.create(Resolution.X)) end local Terrain = workspace.Terrain task.desynchronize() for Y, v in ipairs(Colors) do for X = 1, Resolution.X do local uv = (Vector2.new(X, Y) - Resolution * .5) / (Vector2.one * Resolution.Y) local RayDirection = (CamRot * Vector3.new(uv.X, uv.Y, 1).Unit) * 750 local Hit = workspace:Raycast(CamPos, RayDirection) if Hit and Hit.Instance ~= Terrain then local Got = ApplyMaterial[Hit.Instance.Material] if Got then local Instance = Hit.Instance local InstanceCF = Instance.CFrame local Pos = Hit.Position local LocalNormal = (InstanceCF - InstanceCF.Position):Inverse() * Hit.Normal local Uv for i, v in next, NormalIds do if math.abs(i:Dot(LocalNormal)) > .5 then Uv = v(InstanceCF:Inverse() * Pos) end end v[X] = Got(Uv, Hit) else local Checker = (math.floor(X * .125) + math.floor(Y * .125)) % 2 Checker = Checker v[X] = Vector3.new(Checker, .3 * Checker, Checker) end else local Checker = (math.floor(X * .125) + math.floor(Y * .125)) % 2 Checker = Checker * .2 + .8 v[X] = Vector3.one * Checker end end if Y % 10 == 0 then task.wait() end end task.synchronize() local PixelSize = Vector3.new(.05, .05, 0) local RefPixel = Instance.new("Part") RefPixel.Size = Vector3.zero RefPixel.CanCollide = false RefPixel.CanQuery = false RefPixel.CanTouch = false RefPixel.CastShadow = false RefPixel.Anchored = true local Mesh = Instance.new("SpecialMesh", RefPixel) Mesh.MeshId = "rbxassetid://6867201124" Mesh.Scale = PixelSize local Offset = Vector3.new(PixelSize.X * Resolution.X * .5, PixelSize.Y * Resolution.Y * .5) local _CF = CF * CFrame.Angles(0, math.pi, 0) + Vector3.yAxis * (Resolution.Y * PixelSize.Y * .5 - 3) for Y = 1, Resolution.Y do local Colors = Colors[Y] local Skip = 0 for X = 1, Resolution.X do if Skip > 0 then Skip = Skip - 1 continue end local Color = Colors[X] Skip = Skip + 1 while Colors[X + Skip] and (Colors[X + Skip] - Color).Magnitude < LossAmount do Skip = Skip + 1 end Skip = Skip - 1 local Pixel = RefPixel:Clone() Pixel.Color = Color3.new(Color.X, Color.Y, Color.Z) if Skip ~= 0 then Pixel.Mesh.Scale = PixelSize * Vector3.new(Skip + 1, 1, 1) Pixel.CFrame = _CF + _CF * (Vector3.new(PixelSize.X * (X + Skip * .5), PixelSize.Y * Y, 3) - Offset) - _CF.Position else Pixel.CFrame = _CF + _CF * (Vector3.new(PixelSize.X * X, PixelSize.Y * Y, 3) - Offset) - _CF.Position end Pixel.Parent = script end if Y % 4 == 0 then task.wait() end end